package com.algorithm.tencent;


import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ThreeSum {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 5, 4, 8, 3, -1, -4, -8, -9, 3, 5};
        List<List<Integer>> lists = threeSum(arr);
        for (List<Integer> list : lists) {
            for (Integer integer : list) {
                System.out.print(integer + "\t");
            }
            System.out.println();
        }
    }

    public static List<List<Integer>> threeSum(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int key = nums[i];
            Integer old = map.get(key);
            map.put(key, old == null ? 0 : (old++));
        }

        return null;
    }
}
class Solution {
    public static void main(String[] args) {
        System.out.println(isPalindrome("A man, a plan, a canal: Panama"));
    }
    public static boolean isPalindrome(String s) {
        int i = 0;
        int j = s.length()-1;
        while(i<j){
            while (i<j && !isLegalChar(s.charAt(i))){
                i++;
            }
            while (i<j &&!isLegalChar(s.charAt(j))){
                j--;
            }
            if (i >= j){
                break;
            }
            if (!normalizeCompare(s,i,j)){
                return false;
            }else {
                i++;
                j--;
            }
        }
        return true;
    }

    public static boolean normalizeCompare(String s,int i,int j){
        char left = s.charAt(i);
        char right = s.charAt(j);
        if (left >=97){
            left -=32;
        }
        if (right >=97){
            right -=32;
        }
        return left == right;
    }

    public static boolean isLegalChar(char c){
        boolean flag = true;
        if(c < 48 || c >122){
            flag = false;
        }
        if(c>57 && c<65){
            flag = false;
        }
        if(c>90 && c<97){
            flag = false;
        }
        return flag;
    }
}